package pers.sloera.typing.frame

import java.awt.Container
import java.awt.event.KeyEvent
import java.awt.event.KeyListener
import java.awt.event.MouseEvent
import java.awt.event.MouseListener
import javax.swing.*

/**
 * class pers.sloera.typing.frame
 * user sloera
 * date 8/8/21
 */
class KeyBoard : JFrame, KeyListener, MouseListener {

    var con: Container? = null
    lateinit var jButton: Array<Array<JButton>>
    var jp: JPanel? = null
    var textArea: JTextArea? = null
    var reset: JButton? = null
    private val keys = arrayOf("1234567890-=", "QWERTYUIOP[]", "ASDFGHJKL'", "ZXCVBNM,./")
    constructor(title: String?) : super(title) {
        println("with string")
    }

    constructor() : super("键盘模拟") {
        this.draw()
    }


    fun draw() {
        // super("测试");
        // val f = JFrame(title)
        val tf1 = JTextField()
        tf1.addKeyListener(this)
        tf1.setBounds(50, 50, 150, 20)
        this.add(tf1)
        this.setSize(300, 300)
        this.setLocationRelativeTo(null)
        // this.addKeyListener(this)
        // this.addMouseListener(this)
        this.setLayout(null)
        this.setVisible(true)
    }


    override fun keyTyped(e: KeyEvent?) {
        println(e)
        return
        TODO("Not yet implemented")
    }

    override fun keyPressed(e: KeyEvent?) {
        println(e)
        return
        TODO("Not yet implemented")
    }

    override fun keyReleased(e: KeyEvent?) {
        println(e)
        return
        TODO("Not yet implemented")
    }

    override fun mouseClicked(e: MouseEvent?) {
        println(e)
        return
        TODO("Not yet implemented")
    }

    override fun mousePressed(e: MouseEvent?) {
        println(e)
        return
        TODO("Not yet implemented")
    }

    override fun mouseReleased(e: MouseEvent?) {
        println(e)
        return
        TODO("Not yet implemented")
    }

    override fun mouseEntered(e: MouseEvent?) {
        println(e)
        return
        TODO("Not yet implemented")
    }

    override fun mouseExited(e: MouseEvent?) {
        println(e)
        return
        TODO("Not yet implemented")
    }
}